package com.c.ctgproject.adapter

import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.c.ctgproject.R
import com.c.ctgproject.entity.ListCarWaitingEntrance
import com.c.ctgproject.entity.OldPhotoVideoEntity
import com.c.ctgproject.ui.doorkeeper.car.CarWaitActivity
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.wiget.dialog.ShowImgVideoFragment

/**
 *作者:LiBW
 *创建日期: 2020/9/22
 *描述: 通用图片列表展示
 */
class ImageCommonRvV2Adapter(private val context: AppCompatActivity, private val imageList: List<String>) : RecyclerView.Adapter<ImageCommonRvV2Adapter.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_image_list_second, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val data = imageList[position]

        Glide.with(context).load(data).error(R.drawable.app_icon).into(holder.mImageView)
        holder.mImageView.setOnClickListener {
            ShowImgVideoFragment(data).show(context.supportFragmentManager, "")
        }

    }

    override fun getItemCount(): Int {
        return imageList.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val mImageView: ImageView = itemView.findViewById(R.id.mImageView)
    }
}